<style scoped >
    .repairbody{padding: 15px 0px;height:450px;overflow-y: auto;}
    .repairbody h4{
        padding: 0 15px;
        line-height: 33px;
        border: 1px solid #e5eaee;
        background:-webkit-gradient(linear, 0 0, 0 100%, from(#fbfbfb), to(#f5f5f5));
    }
    .repairbody h4 .repairtitle{
        color: #37b3b3;
        font-weight: normal;
        font-size: 14px;
    }
    .repairbody .repaircont{padding: 15px 16px 20px;}
    .repairbody .repairborder{box-shadow: 0px 0px 3px 0px #cccccc; padding: 0 16px;}
    .repairbody .repairborderlast{ box-shadow: 0px 0px 3px 0px #cccccc;padding: 0 16px;}
    .repairbody .repairborder .ivu-col .ivu-form-item .ivu-form-item-content .ivu-input-wrapper{width: 90%;}
    .passbody{max-height: 500px;overflow-y: auto;}
    .passbody  h4{
        padding: 0 15px;
        line-height: 33px;
        border: 1px solid #e5eaee;
        background:-webkit-gradient(linear, 0 0, 0 100%, from(#fbfbfb), to(#f5f5f5));
    }
    .passbody  h4 .passtitle{
        color: #37b3b3;
        font-weight: normal;
        font-size: 14px;
    }
    .passbody .passcont{padding: 15px 16px 0px;}
    .passbody .passcont .ivu-col-span-12 .ivu-form-item .ivu-form-item-content .ivu-input-wrapper{width: 90%;}
    .passbody .passcont .ivu-form-item .ivu-form-item-content .ivu-select{width: 90%;}
    .passbody .passcont .ivu-col-span-12 .ivu-form-item .ivu-form-item-content .ivu-date-picker{width: 90%;display: inline-block}
    .passbody .passcont .ivu-col-span-24 .ivu-form-item .ivu-form-item-content .ivu-input-wrapper{width: 95.5%;}
    .passcont button.add{
        background: #37b3b3;
        border: 1px solid #37b3b3;
        color: #ffffff;
        padding: 6px 12px;
    }
    .passcont button.del{
        background: #c7cdcd;
        border: 1px solid #c7cdcd;
        color: #ffffff;
        padding: 6px 12px;
    }
    .passcont button.add:hover{background: #019ea3;}
    .passbody .footer .save:hover{background: #019ea3;}
    .passbody .footer{padding-bottom: 25px;text-align: center;}
    .passbody .footer .save{
        padding: 6px 22px;
        background: #37b3b3;
        border: 1px solid #37b3b3;
        color: #ffffff;
    }
    .passbody .footer .clear{
        padding: 6px 22px;
        background: #c7cdcd;
        border: 1px solid #c7cdcd;
        color: #ffffff;
    }
    .rejectdetail .ivu-form-item .ivu-form-item-content .ivu-input-wrapper{width: 90%;}
</style>
<template>
    <div class="console-product">
        <Row class="position">
            <i-col :xs="12" :sm="10" :md="8" :lg="6" >
                <div class="ivu-breadcrumb">
                    <span class="ivu-breadcrumb-item-link">当前位置：</span>
                    <span class="ivu-breadcrumb-item-link">业务中心</span>
                    <span class="ivu-breadcrumb-item-separator">/</span>
                    <span class="ivu-breadcrumb-item-link">返修审核</span>
                </div>
            </i-col>
        </Row>
        <Modal v-model="repairDetailModal" class-name="popup" @on-cancel="clear('repairValidate')" width="940" class="repairdetail" :mask-closable="false">
            <p slot="header" style="color: #eeebeb;"  v-drag>
                <span>返修订单详情</span>
            </p>
            <div  class="repairbody">
                <h4>
                    <span class="repairtitle">基本信息</span>
                </h4>
                <Form ref="repairValidate" :model="repairValidate" label-position="left" :label-width="90">
                    <Row class="repairborder">
                        <i-col span="6">
                            <Form-item label="单位：" prop="dw">
                                <span>{{repairValidate.dw == 1 ? "量体定制" : repairValidate.dw == 2 ? "团装" : "零售"}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="返修单号：" prop="khdh">
                                <span>{{repairValidate.khdh}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="客户单号：" prop="rckhdh">
                                <span>{{repairValidate.rckhdh}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="量体人员：" prop="ltry">
                                <span>{{repairValidate.ltry}}</span>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row class="repairborder">
                        <i-col span="6">
                            <Form-item label="交货日期：" prop="jhrq">
                                <span>{{repairValidate.jhrq == null ? '': new Date(repairValidate.jhrq).format('yyyy-MM-dd hh:mm:ss')}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="半成品试衣：" prop="sfbcpsy">
                                <span>{{repairValidate.sfbcpsy == 1 ? "是" : "否"}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="费用：" prop="hj">
                                <span>{{repairValidate.hj}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="服装分类：" prop="fzfl">
                                <span>{{repairValidate.fzfl}}</span>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row class="repairborder">
                        <i-col span="6">
                            <Form-item label="审核状态：" prop="estatus">
                                <span>{{repairValidate.estatus == 7 ? "审核" : "未审核" }}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="面料号：" prop="fabricno">
                                <span>{{repairValidate.fabricno}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="申请人：" prop="modifyby">
                                <span>{{repairValidate.modifyby}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="申请时间：" prop="modifytime">
                                <span>{{repairValidate.modifytime == null ? '': new Date(repairValidate.modifytime).format('yyyy-MM-dd hh:mm:ss')}}</span>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row class="repairborder">
                        <i-col span="6">
                            <Form-item label="审核人：" prop="auditby">
                                <span>{{repairValidate.auditby}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="审核时间：" prop="audittime">
                                <span>{{repairValidate.audittime == null ? '': new Date(repairValidate.audittime).format('yyyy-MM-dd hh:mm:ss')}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="创建人：" prop="createby">
                                <span>{{repairValidate.createby}}</span>
                            </Form-item>
                        </i-col>
                        <i-col span="6">
                            <Form-item label="创建时间：" prop="createtime">
                                <span>{{repairValidate.createtime == null ? '': new Date(repairValidate.createtime).format('yyyy-MM-dd hh:mm:ss')}}</span>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row class="repairborderlast">
                        <i-col span="24">
                            <Form-item label="备注信息：" prop="moneyType">
                                <span>{{repairValidate.tranmemo}}</span>
                            </Form-item>
                        </i-col>
                    </Row>
                </Form>
                <h4>
                    <span class="repairtitle">订单明细</span>
                </h4>
                <div class="repaircont">
                    <Table stripe border :columns="tscddpzmxsColumns" ref="tscddpzmxsData" :data="tscddpzmxsData"></Table>
                </div>
                <h4>
                    <span class="repairtitle">成衣尺寸</span>
                </h4>
                <div class="repaircont">
                    <Table stripe border :columns="tscddcyccsColumns" ref="tscddcyccsData" :data="tscddcyccsData"></Table>
                </div>
                <h4>
                    <span class="repairtitle">工艺信息</span>
                </h4>
                <div class="repaircont">
                    <Table stripe border :columns="tddpzsjxzColumns" ref="tddpzsjxzData" :data="tddpzsjxzData"></Table>
                </div>
                <h4>
                    <span class="repairtitle">刺绣信息</span>
                </h4>
                <div class="repaircont">
                    <Table stripe border :columns="tscddpzcxsColumns" ref="tscddpzcxsData" :data="tscddpzcxsData"></Table>
                </div>
            </div>
            <div slot="footer"></div>
        </Modal>



        <Modal v-model="passModal" class-name="popup" @on-cancel="cancelPass('passValidate')" width="620" class="passdetail" :mask-closable="false">
            <p slot="header" style="color: #eeebeb;"  v-drag>
                <span>请填写通过日期</span>
            </p>
            <div  class="passbody">
                <Form ref="passValidate" :model="passValidate" :rules="rulepassCustom" label-position="left" :label-width="76">
                    <div class="passcont">
                        <Row>
                            <i-col span="12">
                                <Form-item label="通过日期：" prop="jhrq" >
                                    <Date-picker v-model="passValidate.jhrq"></Date-picker>
                                </Form-item>
                            </i-col>
                            <i-col span="12">
                                <Form-item label="考核扣分：" prop="score"  >
                                    <Input v-model="passValidate.score" ></Input>
                                </Form-item>
                            </i-col>
                            <i-col span="12">
                                <Form-item label="费用调整：" prop="hj">
                                    <Input v-model="passValidate.hj"></Input>
                                </Form-item>
                            </i-col>
                            <i-col span="12">
                                <Form-item label="原始价格：" prop="price">
                                    <span>{{passValidate.price}}</span>
                                </Form-item>
                            </i-col>
                            <i-col span="24">
                                <Form-item label="备注：" prop="tranmemo">
                                    <Input type="textarea" :rows="1" v-model="passValidate.tranmemo"></Input>
                                </Form-item>
                            </i-col>
                            <i-col span="12">
                                <Form-item label="责任归属：" prop="zrgs">
                                    <Select v-model="passValidate.zrgs">
                                        <Option v-for="item in zrgsList" :value="item.value" :key="item">{{ item.label }}</Option>
                                    </Select>
                                </Form-item>
                            </i-col>
                        </Row>
                    </div>
                </Form>
                <h4 >
                    <span class="passtitle">责任判断修改</span>
                </h4>
                <div class="passcont">
                    <Form ref="formResponsibility" :model="formResponsibility" label-position="left" :label-width="76">
                        <Row v-for="(item, index) in formResponsibility.items">
                            <i-col span="9">
                                <Form-item :label="item.fzfl">
                                    <Select v-model="item.zrpd" @on-change="selectzrpd(index,item.zrpd)">
                                        <Option v-for="item in zrpdList" :value="item.value" :key="item">{{ item.label }}</Option>
                                    </Select>
                                </Form-item>
                            </i-col>
                            <i-col span="9">
                                <Form-item label="二级判定:">
                                    <Select  v-model="item.valid">
                                        <Option v-for="item in item.validList" :value="item.code" :key="item">{{ item.nameZh }}</Option>
                                    </Select>
                                </Form-item>
                            </i-col>
                            <i-col span="6" style="text-align: center">
                                <Button class="add" @click="addPass(index)" >添加</Button>&nbsp;&nbsp;
                                <Button class="del" @click="delPass(index)">删除</Button>
                            </i-col>
                        </Row>
                    </Form>
                </div>
                <div class="footer">
                    <Button class="save" :loading="modal_loading" @click="savePass('passValidate')">保存</Button>
                    <Button class="clear" @click="clearPass('passValidate')">清空</Button>
                </div>
            </div>
            <div slot="footer"></div>
        </Modal>
        <Modal v-model="rejectModal" class-name="popup" @on-cancel="cancelReject('rejectValidate')" width="360" class="rejectdetail" :mask-closable="false">
            <p slot="header" style="color: #eeebeb;"  v-drag>
                <span>请填写驳回原因</span>
            </p>
            <div  class="rejectbody">
                <Form ref="rejectValidate" :model="rejectValidate" :rules="rulerejectCustom" label-position="left" :label-width="50">
                    <Form-item label="原因：" prop="bhReason">
                        <Input type="textarea" :rows="1" v-model="rejectValidate.bhReason"></Input>
                    </Form-item>
                </Form>
            </div>
            <div slot="footer">
                <div class="footer">
                    <Button class="save" :loading="modal_loading" @click="saveReject('rejectValidate')">保存</Button>
                    <Button class="clear" @click="clearReject('rejectValidate')">清空</Button>
                </div>
            </div>
        </Modal>
        <div class="console-product-contcent" id="contcentHeight" :style="{height:height +'px'}">
            <Form class="searchform" ref="repairForm" :model="repairForm" inline>
                <Form-item label="返修单号:"  prop="khdh" :label-width="65" style="width: 190px">
                    <Input v-model="repairForm.khdh" @on-enter="repairFormSearch"></Input>
                </Form-item>
                <Form-item label="客户单号:"  prop="rckhdh" :label-width="65" style="width: 190px">
                    <Input v-model="repairForm.rckhdh" @on-enter="repairFormSearch"></Input>
                </Form-item>
                <Form-item label="审核状态:"  prop="estatus" :label-width="65" style="width: 135px">
                    <Select v-model="repairForm.estatus">
                        <Option v-for="item in estatusList" :value="item.value" :key="item">{{ item.label }}</Option>
                    </Select>
                </Form-item>
                <Form-item label="创建时间:"  prop="createtime" :label-width="65" style="width: 270px">
                    <Date-picker type="daterange" v-model="repairForm.createtime"  format="yyyy-MM-dd" :options="creatDate0ptions" placeholder="选择日期" style="width: 200px"></Date-picker>
                </Form-item>
                <Form-item label="审核时间:"  prop="audittime" :label-width="65" style="width: 270px">
                    <Date-picker type="daterange" v-model="repairForm.audittime"  format="yyyy-MM-dd" :options="auditDate0ptions" placeholder="选择日期" style="width: 200px"></Date-picker>
                </Form-item>
                <Form-item>
                    <Button class="search" @click="repairFormSearch">搜索</Button>
                    <Button class="search" @click="repairHistorySearch">搜索历史</Button>
                </Form-item>
            </Form>
            <Loading v-if="spinShow"></Loading>
            <Table v-if="tableShow"  stripe border :columns="repairColumns" ref="repairData" :data="repairData"></Table>
        </div>
        <Row style="background-color: #ffffff;margin-top: 1px;">
            <Col>
            <div v-if="tableShow" class="tablepage clearfix">
                <div class="fl">
                    <span>共</span>
                    <span class="num">{{total}}</span>
                    <span>条记录</span>
                    <span>{{currentPage}}/{{pageTotal}}页</span>
                </div>
                <div class="fr">
                    <Page :total="total" :page-size="pageSize" :current="currentPage" placement="top" show-elevator show-sizer @on-change="changePage" @on-page-size-change="changeSize"></Page>
                </div>
            </div>
            </Col>
        </Row>
    </div>
</template>
<script>
    // 导入要用到的子组件
    import Loading from '../../components/loading'
    import ICol from "../../../node_modules/iview/src/components/grid/col";
    export default {
        data () {
            const validateJhrq = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请填写通过日期'));
                } else {
                    callback();
                }
            };
            const validateScore = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请填写考核扣分'));
                } else if (value < 0 || value > 12 ) {
                    callback(new Error('分数的范围为0-12分!'));
                } else if (!/^[0-9]*$/.test(value)) {
                    callback(new Error('请输入数字!'));
                } else {
                    callback();
                }
            };
            const validateHj = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请填写费用调整'));
                } else if (value < 0) {
                    callback(new Error('价格为正数'));
                } else if (!/^[0-9]*$/.test(value)) {
                    callback(new Error('请输入数字!'));
                } else {
                    callback();
                }
            };
            const validatebhReason = (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请填写驳回原因'));
                } else if (value.length > 100 ) {
                    callback(new Error('驳回原因过长'));
                } else {
                    callback();
                }
            };
            return {
                modal_loading: false,
                self: this,
                total: 0,//总条数
                currentPage: 1,//当前页
                pageTotal: 1,//总页数
                pageSize: 10,//默认每页显示数量
                height: 1000,//表单高度
                spinShow: true,//加载层，默认显示
                tableShow: false,//表格层，默认隐藏
                repairDetailModal:false,//查看弹窗
                //状态列表
                estatusList: [
                    {
                        value: ' ',
                        label: '全部'
                    },
                    {
                        value: '7',
                        label: '审核'
                    },
                    {
                        value: '1',
                        label: '未审核'
                    },
                ],
                repairForm: {//条件查询
                    khdh: '',
                    rckhdh: '',
                    estatus: ' ',
                    createtime: [new Date().getTime() - 3600 * 1000 * 24 * 7,new Date()],
                    audittime: [new Date().getTime() - 3600 * 1000 * 24 * 7,new Date()],
                    type:"0"
                },
                creatDate0ptions: {
                    shortcuts: [
                        {
                            text: '最近一周',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                                return [start, end];
                            }
                        },
                        {
                            text: '最近一个月',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                                return [start, end];
                            }
                        },
                        {
                            text: '最近三个月',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                                return [start, end];
                            }
                        }
                    ]
                },
                auditDate0ptions :{
                    shortcuts: [
                        {
                            text: '最近一周',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                                return [start, end];
                            }
                        },
                        {
                            text: '最近一个月',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                                return [start, end];
                            }
                        },
                        {
                            text: '最近三个月',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                                return [start, end];
                            }
                        }
                    ]
                },
                repairData:[],//数据
                repairColumns:[
                    {
                        width:'9%',
                        title: '返修单号',
                        key: 'khdh',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.khdh,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.khdh)]);
                        }
                    },
                    {
                        width:'9%',
                        title: '客户单号',
                        key: 'rckhdh',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.rckhdh,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.rckhdh)]);
                        }
                    },
                    {
                        width:'8%',
                        title: '创建时间',
                        key: 'createtime',
                        render: (h, params) => {
                            const text = new Date(params.row.createtime).format("yyyy-MM-dd hh:mm:ss");
                            return h('Tooltip', {
                                props: {
                                    content: text,
                                    placement:"bottom-start"
                                }
                            }, [h('span', text)]);
                        }
                    },
                    {
                        width:'8%',
                        title: '交货日期',
                        key: 'jhrq',
                        render: (h, params) => {
                            const text = params.row.jhrq != null ? new Date(params.row.jhrq).format('yyyy-MM-dd') : "";
                            return h('Tooltip', {
                                props: {
                                    content: text,
                                    placement:"bottom-start"
                                }
                            }, [h('span', text)]);
                        }
                    },
                    {
                        width:'8%',
                        title: '量体人员',
                        key: 'ltry',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.ltry,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.ltry)]);
                        }
                    },
                    {
                        width:'6%',
                        title: '半成品试衣',
                        key: 'sfbcpsy',
                        render: (h, params) => {
                            const text = params.row.sfbcpsy == 1 ? '是' : '否';
                            return h('Tooltip', {
                                props: {
                                    content: text,
                                    placement:"bottom-start"
                                }
                            }, [h('span', text)]);
                        }
                    },
                    {
                        width:'4%',
                        title: '费用',
                        key: 'hj',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.hj,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.hj)]);
                        }
                    },
                    {
                        width:'10.5%',
                        title: '服装分类',
                        key: 'fzfl',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.fzfl,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.fzfl)]);
                        }
                    },
                    {
                        width:'6.5%',
                        title: '申请人',
                        key: 'modifyby',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.modifyby,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.modifyby)]);
                        }
                    },
                    {
                        width:'6%',
                        title: '审核人',
                        key: 'auditby',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.auditby,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.auditby)]);
                        }
                    },
                    {
                        width:'8%',
                        title: '审核时间',
                        key: 'audittime',
                        render: (h, params) => {
                            const text = params.row.audittime != null ? new Date(params.row.audittime).format('yyyy-MM-dd hh:mm:ss') : "";
                            return h('Tooltip', {
                                props: {
                                    content: text,
                                    placement:"bottom-start"
                                }
                            }, [h('span', text)]);
                        }
                    },
                    {
                        width:'17%',
                        title: '操作',
                        key: 'id',
                        render: (h, params) => {
                            return h('div', [
                                h('Button',
                                    {
                                        class:"blue",
                                        on: {
                                            click: () => {
                                                this.showRepair(params.row)
                                            }
                                        }
                                    },
                                    [
                                        h('i', {
                                            class : 'iconfont icon-chakan'
                                        }),
                                        h("span",'查看')
                                    ]),
                                params.row.estatus == 1 ? h('Button',
                                    {
                                        class:"green",
                                        on: {
                                            click: () => {
                                                this.passRepair(params.row)
                                            }
                                        }
                                    },
                                    [
                                        h('i', {
                                            class : 'iconfont icon-tongguo'
                                        }),
                                        h("span",'通过')
                                    ]): "",

                                params.row.estatus == 1 ? h('Button',
                                    {
                                        class:"red",
                                        on: {
                                            click: () => {
                                                this.rejectRepair(params.row)
                                            }
                                        }
                                    },
                                    [
                                        h('i', {
                                            class : 'iconfont icon-bohui1'
                                        }),
                                        h("span",'驳回')
                                    ]) : ""
                            ]);
                        }
                    }
                ],
                //查看
                repairValidate:{
                    dw:'',//单位
                    khdh:'',//返修单号
                    rckhdh:'',//客户单号
                    ltry:'',//量体人员
                    jhrq:'',//交货日期
                    sfbcpsy:'',//半成品试衣
                    hj:'',//费用
                    fzfl:'',//服装分类
                    estatus:'',//审核状态
                    fabricno:'',//面料号
                    modifyby:'',//申请人
                    modifytime:'',//申请时间
                    auditby:'',//审核人
                    audittime:'',//审核时间
                    createby:'',//创建人
                    createtime:'',//创建时间
                    tranmemo:''//备注信息
                },
                tscddpzmxsData:[],
                tscddpzmxsColumns:[//订单明细
                    {
                        title:'序号',
                        width:'4%',
                        type:'index'
                    },
                    {
                        title: '大类',
                        key: 'cloth',
                        width:'16%'
                    },
                    {
                        title: '大类名称',
                        key: 'clothName',
                        width:'16%'
                    },
                    {
                        title: '面料代码',
                        key: 'mlbm',
                        width:'16%'
                    },
                    {
                        title: '数量',
                        key: 'ddsl',
                        width:'16%'
                    },
                    {
                        title: '工艺类型',
                        key: 'gylx',
                        width:'16%'
                    },
                    {
                        title: '加放量',
                        key: 'xwjfl',
                        width:'16%'
                    },
                    {
                        title: '是否半成品',
                        key: 'sfbcpsy',
                        width:'16%',
                        render: (h, params) => {
                            var text = params.row.sfbcpsy == 1 ? '是' : '否';
                            return h('div', [
                                h('span', text)
                            ]);
                        }
                    }
                ],
                tscddcyccsData:[],
                tscddcyccsColumns:[//成衣尺寸
                    {
                        title:'序号',
                        width:'4%',
                        type:'index'
                    },
                    {
                        title: '大类名称',
                        key: 'clothName',
                        width:'32%'
                    },
                    {
                        title: '成衣部位',
                        key: 'partName',
                        width:'32%'
                    },
                    {
                        title: '修改值',
                        key: 'clz',
                        width:'32%'
                    }
                ],
                tddpzsjxzData:[],
                tddpzsjxzColumns:[//工艺信息
                    {
                        title:'序号',
                        width:'4%',
                        type:'index'
                    },
                    {
                        title: '大类名称',
                        key: 'clothName',
                        width:'24%'
                    },
                    {
                        title: '修改工艺',
                        key: 'gydm',
                        width:'24%'
                    },
                    {
                        title: '工艺名称',
                        key: 'gymc',
                        width:'24%'
                    },
                    {
                        title: '工艺备注',
                        key: 'tranmemo',
                        width:'24%'
                    }
                ],
                tscddpzcxsData:[],
                tscddpzcxsColumns:[//刺绣信息
                    {
                        title:'序号',
                        width:'4%',
                        type:'index'
                    },
                    {
                        title: '大类名称',
                        key: 'clothName',
                        width:'16%'
                    },
                    {
                        title: '刺绣位置',
                        key: 'cxwzecode',
                        width:'16%'
                    },
                    {
                        title: '刺绣字体',
                        key: 'ztdnecode',
                        width:'16%'
                    },
                    {
                        title: '刺绣颜色',
                        key: 'cxysecode',
                        width:'16%'
                    },
                    {
                        title: '字号大小',
                        key: 'zhdnid',
                        width:'16%'
                    },
                    {
                        title: '刺绣内容',
                        key: 'cxnr',
                        width:'16%'
                    }
                ],
                passModal:false,//通过弹窗
                zrgsList:[
                    {
                        value: '0',
                        label: '公司原因'
                    },
                    {
                        value: '1',
                        label: '非公司原因'
                    }
                ],
                zrpdList:[
                    {
                        value: '',
                        label: '请选择'
                    },
                    {
                        value: '1',
                        label: '尺寸原因'
                    },
                    {
                        value: '2',
                        label: '做工原因'
                    },
                    {
                        value: '3',
                        label: '版型原因'
                    },
                    {
                        value: '4',
                        label: '面辅料原因'
                    },
                    {
                        value: '5',
                        label: '顾客原因'
                    },
                    {
                        value: '6',
                        label: '更改款式'
                    },
                    {
                        value: '7',
                        label: '更改工艺'
                    },
                    {
                        value: '8',
                        label: '更改配色料'
                    },
                    {
                        value: '9',
                        label: '量体尺寸'
                    },
                    {
                        value: '11',
                        label: '更改刺绣'
                    },
                    {
                        value: '12',
                        label: '特殊处理'
                    },
                    {
                        value: '13',
                        label: '系统'
                    },
                    {
                        value: '14',
                        label: '公差'
                    },
                    {
                        value: '15',
                        label: '风格'
                    },
                    {
                        value: '16',
                        label: '单独整烫'
                    },
                    {
                        value: '17',
                        label: '匹配规则'
                    },
                    {
                        value: '18',
                        label: '发货'
                    }
                ],
                passValidate:{
                    khdh:"",
                    rckhdh:"",
                    jhrq:'',
                    score:'',
                    hj:'',
                    price:'',
                    tranmemo:'',
                    zrgs:'0'
                },
                rulepassCustom:{
                    jhrq: [
                        {required: true, validator: validateJhrq, trigger: 'change'}
                    ],
                    score: [
                        {required: true, validator: validateScore, trigger: 'blur'}
                    ],
                    hj: [
                        {required: true, validator: validateHj, trigger: 'blur'}
                    ]
                },
                formResponsibility: {
                    items:[]
                },
                rejectModal:false,//驳回弹窗
                rejectValidate:{
                    khdh:"",
                    bhReason:''
                },
                rulerejectCustom: {
                    bhReason: [
                        {required: true, validator: validatebhReason, trigger: 'blur'}
                    ]
                },
            }
        },
        //所需子组件
        components: {
            ICol, Loading
        },
        created:function(){
            var width = window.innerWidth;
            if(width >1600){
                this.height=window.innerHeight-200;
            }else if(width > 1440 && width <=1600){
                this.height=window.innerHeight-180;
            }else if(width > 1366 && width <=1440){
                this.height=window.innerHeight-172;
            }else if(width > 1280 && width <=1366){
                this.height=window.innerHeight-166;
            }else if(width > 1024 && width <=1280){
                this.height=window.innerHeight-162;
            }else{
                this.height=window.innerHeight-151;
            }
            if(window.innerWidth > 1600) {
                this.pageSize = 20;
            }
            this.repairData = this.repairTableData(this.repairForm,this.currentPage,this.pageSize);
        },
        mounted() {
            $(".repairbody").scroll(function() {
                if(sessionStorage.getItem("repairbodyScrollTop") == "YES"){
                    $('.repairbody').animate({ scrollTop: 0 }, 1);
                    sessionStorage.setItem("repairbodyScrollTop","NO");
                };
            });
        },
        methods: {
            //查询物流数据，条件，当前页，每页显示多少条
            repairTableData (repairForm,currentPage,pageSize) {
                this.spinShow=true;
                this.tableShow = false;
                var khdh = repairForm.khdh;//返修单号
                var rckhdh = repairForm.rckhdh;//客户单号
                var estatus = repairForm.estatus;//审核状态
                var fromDate = '';//创建开始日期
                var toDate = '';//创建结束日期
                var auditFromDate = '';//审核开始日期
                var auditEndDate = '';//审核结束日期
                var type = repairForm.type;//订单类型
                if(repairForm.createtime.length != 0 && repairForm.createtime[0] != null){
                    var fromDateTime = (new Date(repairForm.createtime[0])).getTime();
                    fromDate = new Date(fromDateTime).format("yyyy-MM-dd");
                    var toDateTime = (new Date(repairForm.createtime[1])).getTime();
                    toDate = new Date(toDateTime).format("yyyy-MM-dd");
                }
                if(repairForm.audittime.length != 0 && repairForm.audittime[0] != null){
                    var auditFromDateTime = (new Date(repairForm.audittime[0])).getTime();
                    auditFromDate = new Date(auditFromDateTime).format("yyyy-MM-dd");
                    var auditEndDateTime = (new Date(repairForm.audittime[1])).getTime();
                    auditEndDate = new Date(auditEndDateTime).format("yyyy-MM-dd");
                }
                let data = {
                    params: {
                        pageIndex : currentPage,
                        pageSize : pageSize,
                        khdh : khdh,
                        rckhdh : rckhdh,
                        estatus : estatus,
                        fromDate : fromDate,
                        toDate : toDate,
                        auditFromDate : auditFromDate,
                        auditEndDate : auditEndDate,
                        type:type
                    }
                }
                axios.get('/repairs',data).then(res => {
                    this.total=res.data.total;
                    this.pageTotal=Math.ceil(res.data.total / pageSize);
                    this.repairData = res.data.data;
                    this.spinShow=false;
                    this.tableShow = true;
                }).catch(err =>{
                })
            },
            //条件查询
            repairFormSearch () {
                this.repairForm.type = '0';
                this.currentPage = 1;
                 this.repairData = this.repairTableData(this.repairForm,this.currentPage,this.pageSize);
            },
            //搜索历史
            repairHistorySearch(){
                this.repairForm.type = '1';
                this.currentPage = 1;
                this.repairData = this.repairTableData(this.repairForm,this.currentPage,this.pageSize);
            },
            //改变页数
            changePage: function (page) {
                this.currentPage=page;
                this.repairData = this.repairTableData(this.repairForm,this.currentPage,this.pageSize);
            },
            //改变每页显示多少条
            changeSize: function (pageSize) {
                this.currentPage=1;
                this.pageSize = pageSize;
                this.pageTotal=Math.ceil(this.total / this.pageSize);
                this.repairData = this.repairTableData(this.repairForm,this.currentPage,this.pageSize);
            },
            //查看详情
            showRepair(row){
                axios.get('/repairs/'+row.scddid+'/'+this.repairForm.type).then(res => {
                    this.repairValidate = res.data.tscdd;
                    this.tscddpzmxsData = res.data.tscddpzmxs;//订单明细
                    var tscddcycc = res.data.tscddcyccMap;//成衣尺寸
                    for(var key in tscddcycc){
                        for(var i in tscddcycc[key]){
                            var cyccObj = tscddcycc[key][i];
                            cyccObj.clothName = key;
                            this.tscddcyccsData.push(cyccObj);
                        }
                    }
                    var tddpzsjxz = res.data.tddpzsjxzMap;//工艺信息
                    for(var key in tddpzsjxz){
                        for(var i in tddpzsjxz[key]){
                            var sjxzObj = tddpzsjxz[key][i];
                            sjxzObj.clothName = key;
                            this.tddpzsjxzData.push(sjxzObj);
                        }
                    }
                    var scddpzcx = res.data.scddpzcxMap;//刺绣信息
                    for(var key in scddpzcx){
                        this.scddpzcxData = scddpzcx[key];
                        for(var i in scddpzcx[key]){
                            var pzcxObj = scddpzcx[key][i];
                            pzcxObj.clothName = key;
                            this.scddpzcxData.push(pzcxObj);
                        }
                    }
                    this.repairDetailModal=true;
                    $(".repairbody").scroll();
                }).catch(err =>{
                })
            },
            //清空
            clear(name){
                this.tddpzsjxzData = [];
                this.tscddcyccsData = [];
                this.scddpzcxData = [];
                this.$refs[name].resetFields();
                this.repairDetailModal = false;
                sessionStorage.setItem("repairbodyScrollTop","YES");
            },


            //打开通过
            passRepair(column){
                this.passModal=true;
                this.passValidate.khdh=column.khdh;
                this.passValidate.rckhdh=column.rckhdh;
                this.passValidate.price = column.hj;
                this.passValidate.tranmemo = "原始订单："+column.rckhdh+" 币种："+column.moneyType;
                var fzflArr = column.fzfl.split("+");
                var clothTypeArr = column.clothType.split(",");
                this.formResponsibility.items = [];
                for(var i=0;i<fzflArr.length;i++){
                    var obj = new Object;
                    obj.clothType = clothTypeArr[i];
                    obj.fzfl = fzflArr[i].split(" ")[1] + ":";
                    obj.zrpd= '';
                    obj.valid='';
                    obj.validList=[],
                    this.formResponsibility.items.push(obj);
                }
                var width = window.innerWidth;
                if(width >1600){
                    $("textarea.ivu-input").attr("style","height:32px");
                }else if(width > 1440 && width <=1600){
                    $("textarea.ivu-input").attr("style","height:28px");
                }else if(width > 1366 && width <=1440){
                    $("textarea.ivu-input").attr("style","height:26px");
                }else if(width > 1280 && width <=1366){
                    $("textarea.ivu-input").attr("style","height:26px");
                }else if(width > 1024 && width <=1280){
                    $("textarea.ivu-input").attr("style","height:26px");
                }else{
                    $("textarea.ivu-input").attr("style","height:26px");
                }
            },
            selectzrpd(index,selection){
                if(selection == ""){
                    this.formResponsibility.items[index].validList = [];
                }else {
                    axios.get('/repairs/responsibles/'+selection).then(res => {
                        this.$nextTick(function(){
                            this.formResponsibility.items[index].validList = res.data;
                        });
                    }).catch(err =>{
                    })
                }
            },
            //添加一行
            addPass (index) {
                this.formResponsibility.items.splice(index+1, 0,{
                    clothType : this.formResponsibility.items[index].clothType,
                    fzfl:this.formResponsibility.items[index].fzfl,
                    zrpd: '',
                    valid:'',
                    validList:[]
                });
            },
            //删除一行
            delPass (index) {
                var count = 0;
                for(var i = 0;i<this.formResponsibility.items.length;i++){
                    if(this.formResponsibility.items[i].clothType == this.formResponsibility.items[index].clothType){
                        count ++;
                    }
                }
                if(count > 1){
                    this.formResponsibility.items.splice(index, 1);
                }else{
                    this.$Message.error('必须至少保留一个该服装的责任原因!');
                }
            },
            //清空通过
            clearPass(name){
                this.passValidate.jhrq = "";
                this.passValidate.score = "";
                this.passValidate.hj = "";
                this.passValidate.tranmemo = "";
                this.passValidate.zrgs = "0";
                for(var i = 0;i<this.formResponsibility.items.length;i++){
                    this.formResponsibility.items[i].zrpd = "";
                }
            },
            //关闭通过
            cancelPass(name){
                this.passModal = false;
                this.$refs[name].resetFields();
            },
            //保存通过
            savePass(name){
                this.modal_loading = true;
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        var khdh = this.passValidate.khdh;
                        var jhrq = "";
                        var dateTime = (new Date(this.passValidate.jhrq)).getTime();
                        jhrq = new Date(dateTime).format("yyyy-MM-dd");
                        var score = this.passValidate.score;
                        var hj = this.passValidate.hj;
                        var rckhdh = this.passValidate.rckhdh;
                        var tranmemo = this.passValidate.tranmemo;
                        var zrgs = this.passValidate.zrgs;
                        var zrpd = "";
                        for(var i=0;i<this.formResponsibility.items.length;i++){
                            zrpd +=  this.formResponsibility.items[i].clothType+":"+this.formResponsibility.items[i].zrpd+"_"+this.formResponsibility.items[i].valid+",";
                        }
                        let data = {
                            khdh : khdh,//返修单号
                            jhrq : jhrq,//通过日期
                            score : score,//考核扣分
                            hj : hj,//费用调整
                            rckhdh:rckhdh,//客户单号
                            tranmemo:tranmemo,//备注
                            zrgs:zrgs,//责任归属
                            zrpd:zrpd//责任判定
                        };

                        axios.put('/repairs/pass', data).then(res => {
                            this.modal_loading = false;
                            this.passModal = false;
                            this.$Message.success('添加成功');
                            this.$refs[name].resetFields();
                            this.repairData = this.repairTableData(this.repairForm,this.currentPage,this.pageSize);
                        }).catch(err =>{
                            this.modal_loading = false;
                        });
                    } else {
                        this.modal_loading = false;
                    }
                })
            },
            //驳回
            rejectRepair(column){
                this.rejectValidate.khdh = column.khdh;
                this.rejectModal = true;
            },
            //清空驳回
            clearReject(name){
                this.$refs[name].resetFields();
            },
            //关闭驳回
            cancelReject(name){
                this.rejectModal = false;
                this.$refs[name].resetFields();
            },
            //保存驳回
            saveReject(name){
                this.modal_loading = true;
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        axios.put('/repairs/reject', this.rejectValidate).then(res => {
                            this.modal_loading = false;
                            this.rejectModal = false;
                            this.$Message.success('成功');
                            this.$refs[name].resetFields();
                            this.repairData = this.repairTableData(this.repairForm,this.currentPage,this.pageSize);
                        }).catch(err =>{
                        });
                    } else {
                        this.modal_loading = false;
                    }
                })
            }
        }
    }
</script>